package com.controller;

import com.base.BaseController;
import com.req.ChannelPageReq;
import com.req.ChannelReq;
import com.req.RssPageReq;
import com.res.ChannelRes;
import com.base.BasePageRes;
import com.res.UserRes;
import com.service.ChannelService;
import com.util.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/channel")
@Api(tags = "频道")
public class ChannelController extends BaseController {
    @Autowired
    private ChannelService channelService;
    @PostMapping("/save")
    @ApiOperation("频道的增删改查")
    public R<ChannelRes> saveChannel(@RequestBody ChannelReq channelReq){
        UserRes user = this.getUser();
        channelReq.setUserId(user.getId());
        return R.ok(channelService.saveChannel(channelReq));
    }
    @PostMapping("/queryPage")
    @ApiOperation("频道分页查询")
    public R<BasePageRes> queryPageByUser(@RequestBody ChannelPageReq pageReq){
        UserRes user = this.getUser();
        pageReq.setUserId(user.getId());
        return R.ok(channelService.queryPage(pageReq,user));
    }
    @PostMapping("/detailPage")
    @ApiOperation("频道详情分页查询")
    public R<BasePageRes> detailPage(@RequestBody RssPageReq pageReq){

        return R.ok(channelService.detailPage(pageReq));
    }

    @PostMapping("/frontqueryPage")
    @ApiOperation("频道分页查询")
    public R<BasePageRes> FrontqueryPage(@RequestBody ChannelPageReq pageReq){
        return R.ok(channelService.frontqueryPage(pageReq));
    }




}
